#include "at89x52.h"
#define RCLK   P1_5   
#define SDATA  P1_6   
#define SCLK   P1_7   
unsigned char lie[8]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};
unsigned char hang[8]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
void delay()
{
 int a,b;
 {
   for(a=100;a>0;a--)
   {
    for(b=200;b>0;b--)
    {
    }
   }
 }
}
void SendData(unsigned char Xdata, unsigned char Ydata)
{
  unsigned char i=0;
  RCLK=0;
  for (i=0;i<8;i++)
  {
      SDATA=Xdata & 0x01;
      SCLK = 0;
	  SCLK = 1;
      
      Xdata=Xdata>>1;
  }
  for (i=0;i<8;i++)
  {
      SDATA=Ydata & 0x01;
     SCLK = 0; 
	 SCLK = 1;
      
      Ydata=Ydata>>1;
  }     
  RCLK=1;
}
void main(void)
{

    while(1)
    {
	int k;
	for(k=0;k<8;k++)
	{
    SendData(0x00,lie[k]);
	delay();
	}
	for(k=7;k>=0;k--)
	{
    SendData(0x00,lie[k]);
	delay();
	}
	for(k=0;k<8;k++)
	{
    SendData(hang[k],0xff);
	delay();
	}
	for(k=0;k<8;k++)
	{
    SendData(hang[k],lie[k]);
	delay();
	}
    }
}